package com.example.base.demo.configuration;


import org.springframework.beans.PropertyEditorRegistrar;
import org.springframework.beans.factory.config.CustomEditorConfigurer;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.*;
import org.springframework.boot.context.properties.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.context.support.ConversionServiceFactoryBean;
import org.springframework.core.annotation.AliasFor;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.beans.PropertyEditor;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

/**
 *
 * @author TangDan
 * @version 1.0
 * @since 2023/3/8
 */
@Configuration(enforceUniqueMethods = false)
public class TestConfiguration{

/*    @Bean("conversionService")
    public ConversionServiceFactoryBean conversionServiceFactoryBean() {
        ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
        IntegerToLocalDateTimeConverter integerToLocalDateTimeConverter = new IntegerToLocalDateTimeConverter();
        HashSet<Converter> converters = new HashSet<>();
        converters.add(integerToLocalDateTimeConverter);
        factoryBean.setConverters(converters);
        return factoryBean;
    }*/

    @Bean
    public CustomEditorConfigurer customEditorConfigurer() {
        CustomEditorConfigurer customEditorConfigurer = new CustomEditorConfigurer();
        customEditorConfigurer.setPropertyEditorRegistrars(new PropertyEditorRegistrar[]{ new CustomMovieEditor() });
        return customEditorConfigurer;
    }



    @Bean
    public TestService testServiceBean(){
        return new TestService();
    }
    @Bean
    public OtherService testServiceBean(TestService testService){
        return new OtherService();
    }

}
